\documentclass[a4paper]{article}
\usepackage{xltxtra}
\usepackage{graphicx}
\usepackage{fontspec}
\usepackage{cite}
\usepackage{geometry}
\usepackage{amsmath}

\geometry{left=20mm,right=20mm,top=20mm,bottom=20mm}
\begin{document}  

\title{Project: Programming}  
\author{Jiang Zhou 3220101339}   
\date{2024.12}  
\maketitle  
\section{test1}
The results are as shown in the terminal. PPform Linear Spline and Linear BSpline are realized.
\subsection*{Linear PPform Spline Interpolation Test Results}
\begin{verbatim}
Linear PPform Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.5
Spline value at x = 1.5 : 0.75
Spline value at x = 2.5 : 1
Spline value at x = 3.5 : 1.25
\end{verbatim}

\subsection*{Linear B-Spline Interpolation Test Results}
\begin{verbatim}
Testing Linear BSpline Interpolation Test Results:
Spline value at x = 0.500000 : 0.500000
Spline value at x = 1.500000 : 0.750000
Spline value at x = 2.500000 : 1.000000
Spline value at x = 3.500000 : 1.250000
\end{verbatim}

\subsection*{Boundary Tests}
\begin{verbatim}
Boundary tests:
x = 0.000000, Interpolated value = 0.000000
x = 4.000000, Interpolated value = 1.000000
\end{verbatim}

\subsection*{Testing Out-of-Range Value}
\begin{verbatim}
Testing out-of-range value:
Error: (x = -1.0)x is out of range.
Error: (x = 5.0)x is out of range.
\end{verbatim}


\section{test2}
\begin{verbatim}
Test2(PPForm):
Uniform node natural PPform Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617908
Spline value at x = 1.5 : -0.0978446
Spline value at x = 2.5 : 0.038066
Spline value at x = 3.5 : -0.00811341
Uniform node complete PPform Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617908
Spline value at x = 1.5 : -0.0978446
Spline value at x = 2.5 : 0.038066
Spline value at x = 3.5 : -0.00811341
Uniform node periodic PPform Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617139
Spline value at x = 1.5 : -0.0974166
Spline value at x = 2.5 : 0.0371227
Spline value at x = 3.5 : -0.00476797
Non-uniform node natural PPform Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.619221
Spline value at x = 1.5 : -0.102753
Spline value at x = 2.5 : 0.0391228
Spline value at x = 3.5 : -0.00659933
Non-uniform node complete PPform Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617945
Spline value at x = 1.5 : -0.0981026
Spline value at x = 2.5 : 0.0390607
Spline value at x = 3.5 : -0.0133216
Non-uniform node periodic PPform Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617359
Spline value at x = 1.5 : -0.0971902
Spline value at x = 2.5 : 0.035997
Spline value at x = 3.5 : -0.00854687
\end{verbatim}


\section{test3}
\begin{verbatim}
Test3(BSpline):
Uniform node natural BSpline Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617851
Spline value at x = 1.5 : -0.0976345
Spline value at x = 2.5 : 0.0372822
Spline value at x = 3.5 : -0.00518821
Uniform node complete BSpline Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617851
Spline value at x = 1.5 : -0.0976345
Spline value at x = 2.5 : 0.0372822
Spline value at x = 3.5 : -0.00518821
Uniform node periodic BSpline Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617846
Spline value at x = 1.5 : -0.0976099
Spline value at x = 2.5 : 0.0371886
Spline value at x = 3.5 : -0.00483839
Non-uniform node natural BSpline Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617923
Spline value at x = 1.5 : -0.0979923
Spline value at x = 2.5 : 0.0386418
Spline value at x = 3.5 : -0.0113812
Non-uniform node complete BSpline Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617945
Spline value at x = 1.5 : -0.0981026
Spline value at x = 2.5 : 0.0390607
Spline value at x = 3.5 : -0.0133216
Non-uniform node periodic BSpline Spline Interpolation Test Results:
Spline value at x = 0.5 : 0.617919
Spline value at x = 1.5 : -0.0979734
Spline value at x = 2.5 : 0.03857
Spline value at x = 3.5 : -0.0110489
\end{verbatim}


\section{test4}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/test4.png}
    \caption{Spline comparison}
\end{figure}

As shown in Figure 1, the curves are the same with the same interpolation points and the same boundary conditions in ppForm and BSpline format.
\section{test sphere}
By using the method of polar coordinate mapping, we realize the spherical spline fitting.
Original Points (x, y, z):
\begin{verbatim}
(0.5, 0.6, 0.6245)
(0.7, 0.1, 0.707107)
(0.3, -0.6, 0.74162)
(0.5, 0.7, 0.509902)
(-0.6, 0.1, 0.793725)
\end{verbatim}

Fitted Sphere Spline Points:
\begin{verbatim}
(-0.934143, 0.155691, 0.32115)
(-0.036266, -0.999259, 0.0129118)
(-0.0187583, -0.9998, 0.00692509)
(-0.012974, -0.999903, 0.00497327)
(-0.0101141, -0.999941, 0.00403155)
(-0.00842518, -0.999958, 0.00349775)
...
\end{verbatim}
\section{Problem A}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/A_combined.png}
    \caption{A}
\end{figure}
\begin{verbatim}
N, Max Error
N = 6, Max Error = 0.128379
N = 11, Max Error = 0.0841251
N = 21, Max Error = 0.00805262
N = 41, Max Error = 0.000341762
N = 81, Max Error = 0.000144731
\end{verbatim}
As shown in the Figure 2 and the terminal output, the larger the number of subintervals, the smaller the spline curve error and convergence rate
\section{Problem B}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/B_57.png}
    \caption{B:3.57}
\end{figure}
\begin{figure}
    \centering7
    \includegraphics[width=0.5\linewidth]{../figure/B_58.png}
    \caption{B:3.58}
\end{figure}
Program is implemented in the file src/UniqueSpline.hpp in order to realize the quadratic B-splines which correspond to Theorems 3.58.\\
The Figure 3 and Figure 4 is to compare the difference in function\(f(x)=\frac{1}{1+x^2}\) between two different interpolation methods

\section{Problem C}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/C_1.png}
    \caption{C:1}
\end{figure}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/C_2.png}
    \caption{C:2}
\end{figure}
The polynomial corresponding to the exact function is shown in the Figure 5 and Figure 6.
\section{Problem D}
I chose to explore problem D using the functions and interpolation nodes from problem C.
\begin{verbatim}
Interpolation Errors for BSpline:
ES(-3.5) = 0.000669568
ES(-3) = 0
ES(-0.5) = 0.0205289
ES(0) = 0
ES(0.5) = 0.0205289
ES(3) = 0
ES(3.5) = 0.000669568
Interpolation Errors for SpecialSpline:
ES(-3.5) = 0
ES(-3) = 0.000286152
ES(-0.5) = 0
ES(0) = 0.120226
ES(0.5) = 0
ES(3) = 0.000286152
ES(3.5) = 0
\end{verbatim}
\subsection*{Why are some of the errors close to machine precision?}
Since these points are interpolating nodes, the end result should be machine precision.
\subsection*{Which of the two B-splines is more accurate?}
The B-Spline is more accurate than the SpecialSpline, as it produces significantly smaller interpolation errors overall. Specifically, its errors are closer to machine precision at all interpolating nodes, and it avoids the larger errors observed in the SpecialSpline.
For Example, in SpecialSpline \(E_S(0)=0.120226\).
\section{Problem E}
\subsection{$r_1$}
As shown in Figure 7 and Figure 8.\\
Periodic boundary conditions are appropriate here because the heart-shaped curve is end to end.\\
\subsubsection*{Control Interpolation}

Cubic Splines: Focus on passing through a set of given data points (interpolation).  Each segment of the spline is a piece of a polynomial function that fits the data points exactly.\\
Cubic Bézier Curves: Are defined by a set of control points that do not necessarily lie on the curve itself.  The curve is influenced by the placement and weight of these control points, allowing for more intuitive control over the shape of the curve.
\subsubsection*{Continuity}

Cubic Splines: Ensure continuity of the first and second derivatives across the entire curve, providing a smooth transition between segments.  This is particularly important for applications requiring high smoothness.\\
Cubic Bézier Curves: Can also be made smooth, but the smoothness is a result of the control points' arrangement.  Adjusting control points can introduce discontinuities in the derivatives if not done carefully.
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/E1_CL.png}
    \caption{E1 cumulative chordal length}
\end{figure}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/E1_EN.png}
    \caption{E1 Equidistant nodes}
\end{figure}
\subsection{$r_2$}
As shown in Figure 9 and Figure 10.
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/E2_CL.png}
    \caption{E1 cumulative chordal length}
\end{figure}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/E2_EN.png}
    \caption{E1 Equidistant nodes}
\end{figure}
\subsection{$r_3$}
As shown in Figure 11 and Figure 12.
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/Chordal Fitted Curves.png}
    \caption{E1 cumulative chordal length}
\end{figure}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/Equidistant Fitted Curves.png}
    \caption{E1 Equidistant nodes}
\end{figure}
\section{Problem F}
\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/F1.png}
    \caption{F:N=1}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[width=0.5\linewidth]{../figure/F2.png}
    \caption{F:N=2}
\end{figure}
\end{document}  
